package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.HjlyNew;
import com.ruoyi.system.mapper.HjlyNewMapper;
import com.ruoyi.system.service.IHjlyNewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 新闻Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-03-11
 */
@Service
public class HjlyNewServiceImpl implements IHjlyNewService 
{
    @Autowired
    private HjlyNewMapper hjlyNewMapper;

    /**
     * 查询新闻
     * 
     * @param newId 新闻主键
     * @return 新闻
     */
    @Override
    public HjlyNew selectHjlyNewByNewId(Integer newId)
    {
        return hjlyNewMapper.selectHjlyNewByNewId(newId);
    }

    /**
     * 查询新闻列表
     * 
     * @param hjlyNew 新闻
     * @return 新闻
     */
    @Override
    public List<HjlyNew> selectHjlyNewList(HjlyNew hjlyNew)
    {
        return hjlyNewMapper.selectHjlyNewList(hjlyNew);
    }

    /**
     * 新增新闻
     * 
     * @param hjlyNew 新闻
     * @return 结果
     */
    @Override
    public int insertHjlyNew(HjlyNew hjlyNew)
    {
        hjlyNew.setCreateTime(DateUtils.getNowDate());
        return hjlyNewMapper.insertHjlyNew(hjlyNew);
    }

    /**
     * 修改新闻
     * 
     * @param hjlyNew 新闻
     * @return 结果
     */
    @Override
    public int updateHjlyNew(HjlyNew hjlyNew)
    {
        hjlyNew.setUpdateTime(DateUtils.getNowDate());
        return hjlyNewMapper.updateHjlyNew(hjlyNew);
    }

    /**
     * 批量删除新闻
     * 
     * @param newIds 需要删除的新闻主键
     * @return 结果
     */
    @Override
    public int deleteHjlyNewByNewIds(Integer[] newIds)
    {
        return hjlyNewMapper.deleteHjlyNewByNewIds(newIds);
    }

    /**
     * 删除新闻信息
     * 
     * @param newId 新闻主键
     * @return 结果
     */
    @Override
    public int deleteHjlyNewByNewId(Integer newId)
    {
        return hjlyNewMapper.deleteHjlyNewByNewId(newId);
    }

    /**
     * 首页查询新闻点赞人数前五
     *
     * @param hjlyNew 新闻
     * @return 新闻集合
     */
    @Override
    public List<HjlyNew> selectHjlyNewListTop5(HjlyNew hjlyNew) {
        return hjlyNewMapper.selectHjlyNewListTop5(hjlyNew);
    }
}
